/**
knihovna interpretu
29.11.2011
RA
**/

#ifndef INTERPRET_H
#define INTERPRET_H

#include <stdbool.h>
#include "ilist.h"
#include "hash.h"

typedef enum vartype {

  vard = 0,
  varc,
  varb,
  varn
} VType;

typedef enum etype {

  intererror = 4,
  heaperror
} inerror;

typedef struct varTable{
    VType vartyp;
    char* varName;
    double intVal;
    char* charVal;
    bool boolVal;
    struct varTable *varNext;
} *variab;

typedef struct intTable {
    variab varCache;
    char*   FName;
    struct intTable *fNext;
    tInstructionPtr retLabel;
    char* retName;
} *interCache;

typedef struct {
    variab Act;
    variab First;
} inIList;

typedef struct {
    interCache Act;
    interCache First;
} inFList;

typedef struct fcTable {
  char* name;
  tInstructionPtr label;
  struct fcTable *fcNext;
} *fcLabels;

typedef struct {
    fcLabels Act;
    fcLabels First;
} inLabels;

inLabels LABLIST;
inIList VARLIST;
inFList FCLIST;
static int CONT = -1;
static int nil = -5;


void EXsearch(inIList *, char *);
void initCACHE(inFList *);
void initVCACHE(inIList *);
void initLCACHE(inLabels *);
int makeFLIST(char *, inFList *);
int makeLLIST(char *, inLabels *, tIList *);
int write(inIList *, char *);
int read(inIList *, char *, enumSTypes, int);
int IN_add(inIList *, char *, char *, char *);
int IN_sub(inIList *, char *, char *, char *);
int IN_mul(inIList *, char *, char *, char *);
int IN_div(inIList *, char *, char *, char *);
int IN_neg(inIList *, char *, char *);
int IN_less(inIList *, char *, char *, char *);
int IN_lesseq(inIList *, char *, char *, char *);
int IN_grt(inIList *, char *, char *, char *);
int IN_grteq(inIList *, char *, char *, char *);
int IN_genvar(inFList *, inIList *, char *);
int IN_movC(inIList *, char *, char *);
int IN_movD(inIList *, char *, double);
int IN_movB(inIList *, char *, bool);
int IN_conc(inIList *, char *, char *, char *);
int IN_addchar(inIList *, char *, char *);
int IN_eq(inIList *, char *, char *, char *);
int IN_neq(inIList *, char *, char *, char *);
int IN_type(inIList *, char *, char *);
int IN_substr(inIList *, char *, char *, char *);
int IN_POWA(inIList *, char *, char *);
int IN_ret(inFList *, inIList *, char *);
int IN_disposeIL(inIList *);
int IN_disposeFL(inFList *, inIList *);
int IN_disposeLL(inLabels *);
int IN_disfnc(inFList *, inIList *, char *);
char *IN_goto(inIList *, char *, char *);
int INTERPRET(tIList *);
enumSTypes IN_helpread(inFList *, inIList *, tIList *, int *len);
int IN_MOV(tIList *, inFList *, inIList *);
int IN_push(inFList *, inIList *, char *);
int IN_pop(inIList *, char *);
int IN_copy(inIList *, char *, char *);

#endif

